package com.zwy.customdialog

import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import androidx.activity.ComponentActivity

class MainActivity : ComponentActivity() {

    private var customDialog1: CustomDialog1? = null
    private var customDialog2: CustomDialog2? = null
    private var customDialog3: CustomDialog3? = null

    private var button1: Button? = null
    private var button2: Button? = null
    private var button3: Button? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        button1 = findViewById(R.id.button1)
        button1!!.setOnClickListener {
            customDialog1 = CustomDialog1(this@MainActivity)
//            customDialog!!.setTitle("提示") //设置标题
//            customDialog!!.setMessage("确定退出应用?") //设置提示内容
            customDialog1!!.setOnClickListener(object : CustomDialog1.OnClickListener {
                //设置点击事件
                override fun onCancelClick() {
                    Toast.makeText(this@MainActivity, "你点击了取消键！", Toast.LENGTH_SHORT)
                        .show()
                }

                override fun onConfirmClick() {
                    Toast.makeText(this@MainActivity, "你点击了确认键！", Toast.LENGTH_SHORT)
                        .show()
                }
            })
                .show() //显示对话框
        }

        button2 = findViewById(R.id.button2)
        val wheelViewData: MutableList<String> = ArrayList()
        for(i in 1..100) {
            wheelViewData.add(i.toString())
        }
        button2!!.setOnClickListener {
            customDialog2 = CustomDialog2(this@MainActivity)
            customDialog2!!.setTitle("设置标题") //设置标题
//            customDialog2!!.setWheelViewData(wheelViewData)
//            customDialog!!.setMessage("确定退出应用?") //设置提示内容
            customDialog2!!.setOnClickListener(object : CustomDialog2.OnClickListener {
                //设置点击事件
                override fun onCancelClick() {
                    Toast.makeText(this@MainActivity, "你点击了取消键！", Toast.LENGTH_SHORT)
                        .show()
                }

                override fun onConfirmClick() {
                    Toast.makeText(this@MainActivity, "你点击了确认键！", Toast.LENGTH_SHORT)
                        .show()
                }
            })
                .show() //显示对话框

        }

        button3 = findViewById(R.id.button3)
        button3!!.setOnClickListener {
            customDialog3 = CustomDialog3(this@MainActivity)
//            customDialog!!.setTitle("提示") //设置标题
//            customDialog!!.setMessage("确定退出应用?") //设置提示内容
            customDialog3!!.setOnClickListener(object : CustomDialog3.OnClickListener {
                //设置点击事件
                override fun onCancelClick() {
                    Toast.makeText(this@MainActivity, "你点击了取消键！", Toast.LENGTH_SHORT)
                        .show()
                }

                override fun onConfirmClick(value: String) {
                    Toast.makeText(this@MainActivity,"值为$value",Toast.LENGTH_SHORT).show()

//                    Toast.makeText(this@MainActivity, "你点击了确认键！", Toast.LENGTH_SHORT)
//                        .show()
                }
            })
                .show() //显示对话框
        }
    }
}
